package generators;

import gamebackend.Block;

/**
 * Kills Blocks that have no neighbors to their left or right.
 * @author Jonathan Caddey
 *
 */
public class SoloHorizontalKiller extends AbstractGenerator {

	public SoloHorizontalKiller(Block the_block) {
		super(the_block);
	}

	@Override
	public void generate(Block[][] blocks) {
		for (int col = 0; col < blocks[0].length; col++) {
			if (blocks[0][col] == getBlock()
				&& (col == 0 || blocks[0][col - 1] != getBlock()
				&& (col == blocks[0].length - 1 || blocks[0][col + 1] != getBlock()))) {
					blocks[0][col] = Block.EMPTY_BLOCK;
				}
		}
		
	}
	
}
